import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author Macrydy
 * @date 2022/5/12
 */
public class CopyDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("F:\\FileDemo\\a-copy.txt");
        //字节输入流
        FileInputStream fis = new FileInputStream("F:\\FileDemo\\a.txt");

        //一个一个字节复制
        /*int l;
        while ((l = fis.read()) != -1) {
            fos.write(l);
        }*/

        //多个字节复制
        byte[] bytes = new byte[1024];
        int len;
        while ((len = fis.read(bytes)) != -1){
            fos.write(bytes,0,len);
        }

        fis.close();
        fos.close();
    }
}
